package org.onvivals.module.iot.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.onvivals.common.base.BaseEntity;

import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

/**
 * @Author: Mr.ZS
 * @Date: 2024/9/26 上午11:12
 * @company 湖南葆龄科技有限公司
 **/
/**
 * 设备
 */
@Schema(description="设备")
@Data
@TableName(value = "iot_device")
public class IotDevice extends BaseEntity<IotDevice> {

	@Serial
	private static final long serialVersionUID = 1L;

    /**
     * 设备ID
     */
    @TableId(value = "device_id", type = IdType.ASSIGN_ID)
    @JsonSerialize(using = ToStringSerializer.class)
    @Schema(description="设备ID")
    private Long deviceId;

    /**
     * 设备名称
     */
    @TableField(value = "device_name")
    @Schema(description="设备名称")
    private String deviceName;

    /**
     * 设备编号
     */
    @TableField(value = "serial_number")
    @Schema(description="设备编号")
    private String serialNumber;

    /**
     * 固件版本
     */
    @TableField(value = "firmware_version")
    @Schema(description="固件版本")
    private BigDecimal firmwareVersion;

    /**
     * 设备状态（1-未激活，2-禁用，3-在线，4-离线）
     */
    @TableField(value = "`status`")
    @Schema(description="设备状态（1-未激活，2-禁用，3-在线，4-离线）")
    private Integer status;

    /**
     * 信号强度（
信号极好4格[-55— 0]，
信号好3格[-70— -55]，
信号一般2格[-85— -70]，
信号差1格[-100— -85]）
     */
    @TableField(value = "rssi")
    @Schema(description="信号强度（ 信号极好4格[-55— 0]， 信号好3格[-70— -55]， 信号一般2格[-85— -70]， 信号差1格[-100— -85]）")
    private Byte rssi;

    /**
     * 设备所在地址
     */
    @TableField(value = "network_address")
    @Schema(description="设备所在地址")
    private String networkAddress;

    /**
     * 设备入网IP
     */
    @TableField(value = "network_ip")
    @Schema(description="设备入网IP")
    private String networkIp;

    /**
     * 激活时间
     */
    @TableField(value = "active_time")
    @Schema(description="激活时间")
    private Date activeTime;

    /**
     * 设备摘要，格式[{"name":"device"},{"chip":"esp8266"}]
     */
    @TableField(value = "summary")
    @Schema(description="设备摘要]")
    private String summary;

    /**
     * 图片地址
     */
    @TableField(value = "img_url")
    @Schema(description="图片地址")
    private String imgUrl;

    /**
     * 备注
     */
    @TableField(value = "remark")
    @Schema(description="备注")
    private String remark;

    /**
     * 用户ID
     */
    @Schema(description="用户ID")
	@JsonSerialize(using = ToStringSerializer.class)
	@TableField(value = "user_id",updateStrategy = FieldStrategy.IGNORED)
    private Long userId;

    /**
     * 用户昵称
     */
    @TableField(value = "user_name",updateStrategy = FieldStrategy.IGNORED)
    @Schema(description="用户昵称")
    private String userName;

    /**
     * 模式状态
     */
    @TableField(value = "`type`")
    @Schema(description="模式状态")
    private Boolean type;

    /**
     * 蓝牙ID
     */
    @TableField(value = "bl_id")
    @Schema(description="蓝牙ID")
    private String blId;

	/**
	 * 电量
	 */
	@TableField(value = "battery")
	@Schema(description="电量")
	private Integer battery;

	@TableField(exist = false)
	private IotDeviceUser deviceUser;

	@Schema(description="角色ID")
	@JsonSerialize(using = ToStringSerializer.class)
	private Long roleId;

	@TableField(exist = false)
	private String roleName;

	@Schema(description="角色个性ID")
	@JsonSerialize(using = ToStringSerializer.class)
	@TableField(value = "individuality_id",updateStrategy = FieldStrategy.IGNORED)
	private Long individualityId;

	@TableField(exist = false)
	private String individualityName;

	@Schema(description="音量")
	private Integer volume;

	@TableField(exist = false)
	private double lastValue;

	@TableField(exist = false)
	@JsonSerialize(using = ToStringSerializer.class)
	private Long lastFirmwareId;

	@TableField(exist = false)
	private String code;

	@TableField(value = "time",updateStrategy = FieldStrategy.IGNORED)
	private String time;

	private Integer rms;

	@TableField(value = "content",updateStrategy = FieldStrategy.IGNORED)
	private String content;

	private String hour;

	private String minute;
}
